package com.xmd.red.utils;

import java.io.Serializable;

public class CommonResult implements Serializable{

	private static final long serialVersionUID = 1L;
	private String rcode;
	private String msg;
	private Object data;


	public String getRcode() {
		return rcode;
	}

	public void setRcode(String rcode) {
		this.rcode = rcode;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	/**
	 * 成功,没有返回值
	 * @return
	 */
	public static CommonResult ok(){
		
		CommonResult result = new CommonResult();
		result.setRcode("1");
		result.setData("");
		result.setMsg("成功");
		return result;
	}
	
	/**
	 * 成功,有返回值
	 * @param data 返回值
	 * @return
	 */
	public static CommonResult ok(Object data){
		CommonResult result = new CommonResult();
		result.setRcode("1");
		result.setData(data);
		result.setMsg("成功");
		return result;
	}

	/**
	 * 参数错误
	 * @param msg 错误说明
	 * @return
	 */
	public static CommonResult errorParams(String msg){
		
		CommonResult result = new CommonResult();
		result.setRcode("-1");
		result.setData("");
		result.setMsg(msg);
		return result;
	}
	
	/**
	 * 服务器错误
	 * @param msg 错误说明
	 * @return
	 */
	public static CommonResult serverError(String msg){
		
		CommonResult result = new CommonResult();
		result.setRcode("500");
		result.setData("");
		result.setMsg(msg);
		return result;
	}
}
